package cn.topcodes.tcsf.app.service.impl;

import cn.topcodes.tcsf.admin.commons.domain.Page;
import cn.topcodes.tcsf.admin.commons.generic.GenericService;
import cn.topcodes.tcsf.app.domain.entity.Advice;
import cn.topcodes.tcsf.app.service.AdviceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import tk.mybatis.mapper.entity.Example;

/**
 * @author Unicorn
 * @date 2017/5/5
 */
@Service("adviceService")
@Transactional(readOnly = true)
public class AdviceServiceImpl extends GenericService<Advice> implements AdviceService {

    /**
     * 获取app用户的建议反馈记录分页列表
     *
     * @param appUserId app用户ID
     * @param pageNumber 页号
     * @param pageSize 每页条数
     * @return 分页数据
     */
    @Override
    public Page<Advice> findPageBy(Long appUserId, int pageNumber, int pageSize) {
        Assert.notNull(appUserId, "app用户ID不能为空");
        Example example = this.buildExample();
        example.or().andEqualTo(Advice.FIELD_APP_USER_ID, appUserId);
        return this.findPage(example, pageNumber, pageSize);
    }
}
